package com.ruoyi.web.controller.dmphadoop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dmp.hadoop.config.domain.DmpHadoopConfig;
import com.ruoyi.dmp.hadoop.config.service.IDmpHadoopConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Hadoop配置Controller
 * 
 * @author MquanZeng
 * @date 2021-12-16
 */
@RestController
@RequestMapping("/dmphadoop/config")
public class DmpHadoopConfigController extends BaseController
{
    @Autowired
    private IDmpHadoopConfigService dmpHadoopConfigService;

    /**
     * 查询Hadoop配置列表
     */
    @PreAuthorize("@ss.hasPermi('dmphadoop:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(DmpHadoopConfig dmpHadoopConfig)
    {
        startPage();
        List<DmpHadoopConfig> list = dmpHadoopConfigService.selectDmpHadoopConfigList(dmpHadoopConfig);
        return getDataTable(list);
    }

    /**
     * 导出Hadoop配置列表
     */
    @PreAuthorize("@ss.hasPermi('dmphadoop:config:export')")
    @Log(title = "Hadoop配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmpHadoopConfig dmpHadoopConfig)
    {
        List<DmpHadoopConfig> list = dmpHadoopConfigService.selectDmpHadoopConfigList(dmpHadoopConfig);
        ExcelUtil<DmpHadoopConfig> util = new ExcelUtil<DmpHadoopConfig>(DmpHadoopConfig.class);
        util.exportExcel(response, list, "Hadoop配置数据");
    }

    /**
     * 获取Hadoop配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('dmphadoop:config:query')")
    @GetMapping(value = "/{hcId}")
    public AjaxResult getInfo(@PathVariable("hcId") Long hcId)
    {
        return AjaxResult.success(dmpHadoopConfigService.selectDmpHadoopConfigByHcId(hcId));
    }

    /**
     * 新增Hadoop配置
     */
    @PreAuthorize("@ss.hasPermi('dmphadoop:config:add')")
    @Log(title = "Hadoop配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmpHadoopConfig dmpHadoopConfig)
    {
        return toAjax(dmpHadoopConfigService.insertDmpHadoopConfig(dmpHadoopConfig));
    }

    /**
     * 修改Hadoop配置
     */
    @PreAuthorize("@ss.hasPermi('dmphadoop:config:edit')")
    @Log(title = "Hadoop配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmpHadoopConfig dmpHadoopConfig)
    {
        return toAjax(dmpHadoopConfigService.updateDmpHadoopConfig(dmpHadoopConfig));
    }

    /**
     * 删除Hadoop配置
     */
    @PreAuthorize("@ss.hasPermi('dmphadoop:config:remove')")
    @Log(title = "Hadoop配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hcIds}")
    public AjaxResult remove(@PathVariable Long[] hcIds)
    {
        return toAjax(dmpHadoopConfigService.deleteDmpHadoopConfigByHcIds(hcIds));
    }
}
